package cn.demoncat.util.ocr.huawei.entity;

import cn.demoncat.util.lang.constant.card.BankCardType;
import cn.demoncat.util.lang.entity.card.BankCard;

/**
 * 银行卡
 *
 * @author 延晓磊
 * @since 2020年10月23日
 */
public class BankCardItem {

    // 发卡行
    private String bank_name;
    // 银行卡号
    private String card_number;
    // 有效期开始日期
    private String issue_date;
    // 有效期截止日期
    private String expiry_date;
    // 银行卡类别：借记卡，信用卡，准贷记卡，预付费卡
    private String type;

    /**
     * 转换为通用对象
     *
     * @return
     */
    public BankCard toCommonData(){
        BankCard data = new BankCard();
        data.setBankName(this.getBank_name());
        data.setCardNumber(this.getCard_number());
        data.setExpiryDate("20"+this.getExpiry_date().substring(3,5)+"-"+this.getExpiry_date().substring(0,2)+"-01");
        data.setType("信用卡".equals(this.getType()) ? BankCardType.CREDIT.getType() : BankCardType.DEBIT.getType());
        return data;
    }

    public String getBank_name() {
        return bank_name;
    }

    public void setBank_name(String bank_name) {
        this.bank_name = bank_name;
    }

    public String getCard_number() {
        return card_number;
    }

    public void setCard_number(String card_number) {
        this.card_number = card_number;
    }

    public String getIssue_date() {
        return issue_date;
    }

    public void setIssue_date(String issue_date) {
        this.issue_date = issue_date;
    }

    public String getExpiry_date() {
        return expiry_date;
    }

    public void setExpiry_date(String expiry_date) {
        this.expiry_date = expiry_date;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
